import { get, post } from '@/api/requestApi'

const BASE_URL = '/api/Department/'

const API_URL = {
  GET_DEPARTMENT_LIST: 'GetDepartmentList', //  获取全部部门信息
  GET_DEPARTMENT_BY_CRM_ID: 'GetDepartmentByCrmID', //  根据CRM部门ID获取部门信息
  GET_DEPARTMENT_BY_ID: 'GetDepartmentByID', //  根据部门ID获取部门信息
  GET_DEPARTMENT_PAGE: 'GetDepartmentPage', // 分页获取部门信息
  ADD_DEPARTMENT: 'AddDepartment', // 添加部门
  UPDATE_DEPARTMENT: 'UpdateDepartment' // 修改部门资料
}

for (const i in API_URL) {
  API_URL[i] = BASE_URL + API_URL[i]
}

/**
 * 获取全部部门信息
 * @param data
 * @returns {*}
 * @constructor
 */
export function GetDepartmentList(data) {
  return get(API_URL.GET_DEPARTMENT_LIST, data)
}

/**
 * 根据CRM部门ID获取部门信息
 * @param data
 * @returns {*}
 * @constructor
 */
export function GetDepartmentByCrmID(data) {
  return get(API_URL.GET_DEPARTMENT_BY_CRM_ID, data)
}

/**
 * 根据部门ID获取部门信息
 * @param data
 * @returns {*}
 * @constructor
 */
export function GetDepartmentByID(data) {
  return post(API_URL.GET_DEPARTMENT_BY_ID, data)
}

/**
 * 分页获取部门信息
 * @param data
 * @returns {*}
 * @constructor
 */
export function GetDepartmentPage(data) {
  return post(API_URL.GET_DEPARTMENT_PAGE, data)
}

/**
 * 添加部门
 * @param data
 * @returns {*}
 * @constructor
 */
export function AddDepartment(data) {
  return post(API_URL.ADD_DEPARTMENT, data)
}

/**
 * 修改部门资料
 * @param data
 * @returns {*}
 * @constructor
 */
export function UpdateDepartment(data) {
  return post(API_URL.UPDATE_DEPARTMENT, data)
}

